/*
 * @Description:选择合作类型
 * @Author: iamsmiling
 * @Date: 2021-06-05 17:24:26
 * @LastEditTime: 2021-06-10 19:42:38
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/domain/local/publish/publish_category_entity.dart';
import 'package:credit_business_circle/pages/publish_square/publish_square_controller.dart';
import 'package:credit_business_circle/routes/app_routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class PublishSquarePage extends GetView<PublishSquareController> {
  const PublishSquarePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("选择合作类型"),
      ),
      body: GetBuilder<PublishSquareController>(
          init: PublishSquareController(),
          builder: (_) {
            return Column(
              children: [
                Visibility(
                  visible: _.showTip,
                  child: Stack(
                    children: [
                      Container(
                        padding: EdgeInsets.only(
                            top: R.dimen.dp16,
                            left: R.dimen.dp15,
                            bottom: R.dimen.dp15,
                            right: R.dimen.dp20),
                        alignment: Alignment.centerLeft,
                        width: R.dimen.width,
                        // height: R.dimen.dp60,
                        key: ValueKey("TipItem"),
                        decoration: BoxDecoration(color: R.color.ffd4faed),
                        child: Text(
                          "严禁发布各类违法、违禁信息；\n发布的信息及图片中不可带有任何联系方式，否则将予冻结账号处罚！",
                          style: TextStyle(
                              fontSize: R.dimen.sp11, color: R.color.ff111111),
                        ),
                      ),
                      Positioned(
                          top: R.dimen.dp10,
                          right: R.dimen.dp10,
                          child: GestureDetector(
                              onTap: _.close,
                              child: Image.asset(R.image.closeTip)))
                    ],
                  ),
                ),
                Expanded(
                    child: ListView(
                  padding: EdgeInsets.symmetric(
                      vertical: R.dimen.dp13, horizontal: R.dimen.dp10),
                  shrinkWrap: true,
                  children: [
                    for (PublishCategoryEntity item in _.categories)
                      GestureDetector(
                        onTap: () => Get.toNamed(AppRoutes.publishCenter,
                            arguments: item.type),
                        child: Container(
                          constraints: BoxConstraints(minHeight: R.dimen.dp80),
                          padding: EdgeInsets.fromLTRB(R.dimen.dp25,
                              R.dimen.dp22, R.dimen.dp20, R.dimen.dp14),
                          margin: EdgeInsets.only(bottom: R.dimen.dp13),
                          decoration: BoxDecoration(
                              color: R.color.ffffffff,
                              borderRadius: BorderRadius.circular(R.dimen.sp8)),
                          child: Row(
                            children: [
                              Container(
                                margin: EdgeInsets.only(right: R.dimen.dp28),
                                child: Image.asset(
                                  item.icon,
                                  color: R.color.ff5ec899,
                                ),
                              ),
                              Expanded(
                                  child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Text(
                                    item.label,
                                    style: TextStyle(
                                        fontWeight: FontWeight.w600,
                                        fontSize: R.dimen.sp15,
                                        color: R.color.ff111111),
                                  ),
                                  Container(
                                    margin: EdgeInsets.only(top: R.dimen.dp8),
                                    child: Text(
                                      item.description,
                                      style: TextStyle(
                                          fontSize: R.dimen.sp12,
                                          color: R.color.ff999999),
                                    ),
                                  )
                                ],
                              ))
                            ],
                          ),
                        ),
                      )
                  ],
                ))
              ],
            );
          }),
    );
  }
}
